<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>配置管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="css/redmond/jquery-ui-1.10.3.custom.css" rel="stylesheet"/>
    <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.10.3.custom.js"></script>
    <script type="text/javascript" src="js/datagrid.js"></script>
    <style type="text/css">
    td input{border:1px solid orange;background:yellow;position:absolute;padding:8px 0;text-align:center;width:80%;margin:-17px 0 0 4px;font-size:1.2em;}
    td.input{ padding:0;position:relative;}
	td.blue{background:#bcd4ec;}
    </style>
  </head>
  
  <body>
    <h1 align="center">数据配置表</h1>
    <table align="center">
    <tr>
    <th>类别</th>
    <td>
    	<sf:select id="selector" path="configs"> 
			<sf:option value="" label="--请选择--"/> 
			<sf:options items="${configs}" itemValue="key" itemLabel="value"/>
		</sf:select>
    </td>
    </tr>
    </table>
    <table id="config" width="50%" align="center">
<!--     	<thead><tr><th ></th><th width="20%" align="left">类别</th><th width="50%" align="left">文本</th><th width="20%" align="left">数值</th></tr></thead> -->
<!--     	<tbody></tbody> -->
    </table>
  </body>
  <script type="text/javascript">
  	$(function(){
  		$("#selector").change(function(){
  			$("#config").empty();
  			var selected=$("#selector option:selected").val();
  			if(selected=="")
  				return;
  			var args = {
  				table:$("#config"),
  				dataUrl:"config/category/"+selected,
				deleteUrl:"config/delete",
				changeUrl:"config/update",
				insertUrl:"config/add",
  				dataDescriptions:[
  					{column:"id",value:"id",isHidden:true},
  					{column:"删除",header:"操作",value:"删除",isDelete:true},
  					{column:"类别",header:"类别",value:selected,isConstant:true},
  					{column:"文本",header:"文本",value:"value"},
  					{column:"数值",header:"序号",value:"key"}
  				]
  			};
  			var dg=new DataGrid(args);
  			dg.renderData({insertArgs:{catagory:selected}});
  			dg.renderHeader();
  		});
  	});
  			var builder=function(item){
				var tr=$("<tr></tr>");
					var id=$("<td style='display:none'>"+item.id+"</td>");
					var action=$("<td><u>删除</u></td>");
					action.click(function(){
						_delete($(this).parent(),item.id);
					});
					var catagory=$("<td>"+selected+"</td>");
					var value=$("<td>"+item.value+"</td>");
					var key=$("<td>"+item.key+"</td>");
				tr.append(id).append(action).append(catagory).append(value).append(key);
				return tr;
			};
  </script>
</html>
